package com.bvgol.examples.nio;/**
 * @Classname TestBuffer
 * @Description TODO
 * @Date 2021/6/16 17:26
 * @Created by GUOCHEN
 */

import java.nio.IntBuffer;

/**
 * @program: my-spring-completely
 * @description:
 * @author: GUOCHEN
 * @create: 2021/06/16 17:26
 */
public class TestBuffer {
    public static void main(String[] args) {
        IntBuffer intBuffer =  IntBuffer.allocate(5);

        for (int i = 0; i <intBuffer.capacity() ; i++) {
            intBuffer.put(i);
        }

        //读写切换
        intBuffer.flip();

        while (intBuffer.hasRemaining()){
            System.out.println(intBuffer.get());
        }
    }
}
